<template>
  <div class="content">
    <img
      :src="
        $props.listen.albumCoverPath
          ? `http://fdfs.xmcdn.com/${props.listen.albumCoverPath}`
          : props.listen.coverPath
      "
      class="image"
    />
    <div class="text">
      {{
        props.listen.albumTitle ? props.listen.albumTitle : props.listen.title
      }}
    </div>

    <div class="amount">
      <van-icon name="play-circle-o" class="icon" />
      <div class="count">{{ playCount }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
const props = defineProps(['listen'])
const playCount = ref('')
onMounted(() => {
  if (props.listen.playCount) {
    if (props.listen.playCount > 100000000) {
      playCount.value = (props.listen.playCount / 100000000).toFixed(2) + '亿'
    } else {
      playCount.value = (props.listen.playCount / 10000).toFixed(2) + '万'
    }
  } else {
    if (props.listen.albumPlayCount > 100000000) {
      playCount.value =
        (props.listen.albumPlayCount / 100000000).toFixed(2) + '亿'
    } else {
      playCount.value = (props.listen.albumPlayCount / 10000).toFixed(2) + '万'
    }
  }
})
</script>

<style scoped lang="less">
.content {
  width: 103.55px;
  height: 156.55px;
  display: flex;
  flex-direction: column;
  margin: 0 10px;
  position: relative;

  .image {
    width: 100%;
    height: 103.55px;
    border-radius: 5px;
  }
  .text {
    font-size: 13px;
    overflow: hidden;
    display: -webkit-box;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    letter-spacing: 1px;
    box-sizing: border-box;
    padding: 0 2px;
    margin-top: 6px;
  }
  .amount {
    display: flex;
    position: absolute;
    top: 85px;
    left: 3px;
    .icon {
      color: #b2988c;
      font-size: 10px;
    }
    .count {
      font-size: 12px;
      color: #fff;
      margin-left: 4px;
    }
  }
}
</style>
